<template>
  <div>
    <van-nav-bar
      title="搜索"
      @click-left="$router.push('/app/index')"
      left-arrow
    />
    <van-search v-model="value" placeholder="请输入搜索关键词" />
    <glist :user_list="serch" />
  </div>
</template>
<script>
import glist from "./glist";
export default {
  components: {
    glist,
  },
  data() {
    return {
      value: "",
      user_list: [],
    };
  },
  created() {
    this.List();
  },
  methods: {
    List() {
      this.$axios
        .post("https://api.it120.cc/small4/shop/goods/list")
        .then((res) => {
          console.log(res);
          this.user_list = res.data;
        });
    },
  },
  computed: {
    serch() {
      return this.user_list.filter((item) => {
        return item.name.indexOf(this.value) > -1;
      });
    },
  },
};
</script>